import { StaticSnowFlake } from '@libs/common/utils';

export function genCardId(TemplateId: string, dingId: string) {
  const factor = `${TemplateId}_${dingId}_${StaticSnowFlake.next()}`;
  return factor;
}

export function convertJSONValuesToString(obj: Record<string, any>) {
  const newObj: Record<string, string> = {};
  for (const key in obj) {
    const value = obj[key];
    if (obj.hasOwnProperty(key) && value != null) {
      if (typeof value === 'string') {
        newObj[key] = value;
      } else {
        newObj[key] = JSON.stringify(value);
      }
    }
  }
  return newObj;
}
